package com.mysoft.gfyx.marketdevelop.controller;

import com.mysoft.framework.modeling.dto.ListDataResult;
import com.mysoft.framework.modeling.dto.LoadDataParams;
import com.mysoft.framework.mvc.api.Controller;
import com.mysoft.framework.rpc.annotation.PubAction;
import com.mysoft.framework.rpc.annotation.PubService;
import com.mysoft.framework.rpc.contants.RequestPrefix;
import com.mysoft.gfyx.marketdevelop.controller.dto.ViewTelNumberRequestDto;
import com.mysoft.gfyx.marketdevelop.dao.entity.OpTelViewHistory;
import com.mysoft.gfyx.marketdevelop.mip.dto.GetDeveloperContactsRequestDto;
import com.mysoft.gfyx.marketdevelop.mip.dto.TelViewHistoryRequestDto;
import com.mysoft.gfyx.marketdevelop.service.ProvinceRadarService;
import com.mysoft.gfyx.marketdevelop.service.dto.PickContactsDto;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@PubService(value = "/provinceRadarPub", prefix = RequestPrefix.PUB)
public class ProvinceRadarPubController extends Controller {

    @Resource
    private ProvinceRadarService provinceRadarService;

    @PubAction(value = "/recommendedDevelopers")
    @ApiOperation(value = "/recommendedDevelopers", notes = "推荐开发商")
    public ListDataResult recommendedDevelopers(@RequestBody LoadDataParams options) {
        return provinceRadarService.loadRecommendedDeveloperData(options);
    }

    @PubAction(value = "/recommendedOpportunities")
    @ApiOperation(value = "/recommendedOpportunities", notes = "推荐商机")
    public ListDataResult recommendedOpportunities(@RequestBody LoadDataParams options) {
        return provinceRadarService.loadRecommendedOpportunityData(options);
    }

    @PubAction(value = "/recommendedProjects")
    @ApiOperation(value = "/recommendedProjects", notes = "推荐项目")
    public ListDataResult recommendedProjects(@RequestBody LoadDataParams options) {
        return provinceRadarService.loadRecommendedProjectsData(options);
    }

    @PubAction(value = "/recommendedSuppliers")
    @ApiOperation(value = "/recommendedSuppliers", notes = "推荐供应商")
    public ListDataResult recommendedSuppliers(@RequestBody LoadDataParams options) {
        return provinceRadarService.loadRecommendedSuppliersData(options);
    }

    @PubAction(value = "/viewTelNumber", method = RequestMethod.POST)
    public boolean viewTelNumber(@RequestBody ViewTelNumberRequestDto viewTelNumberRequestDto) {
        provinceRadarService.viewTelNumber(viewTelNumberRequestDto.getTelNumber());
        return true;
    }

    @PubAction(value = "/getContacts", method = RequestMethod.POST)
    public List<PickContactsDto> getContacts(@RequestBody GetDeveloperContactsRequestDto getDeveloperContactsRequestDto) {
        return provinceRadarService.getContacts(getDeveloperContactsRequestDto);
    }

    @PubAction(value = "/telViewHistory", method = RequestMethod.POST)
    public Map<String, OpTelViewHistory> telViewHistory(@RequestBody TelViewHistoryRequestDto telViewHistoryRequestDto) {
        return provinceRadarService.getTelViewHistories(telViewHistoryRequestDto.getMobileList());
    }

}
